package com.kaifamiao.month03.day0316;

import java.util.Arrays;

public class Poetry {

    public static void main(String[] args) {
        char[][] poetry = new char[8][];
        poetry[0] = "北国风光，千里冰封，万里雪飘。".toCharArray();
        poetry[1] = "望长城内外，惟余莽莽；大河上下，顿失滔滔。".toCharArray();
        poetry[2] = "山舞银蛇，原驰蜡象，欲与天公试比高。".toCharArray();
        poetry[3] = "须晴日，看红装素裹，分外妖娆。".toCharArray();
        poetry[4] = "江山如此多娇，引无数英雄竞折腰。".toCharArray();
        poetry[5] = "惜秦皇汉武，略输文采；唐宗宋祖，稍逊风骚。".toCharArray();
        poetry[6] = "一代天骄，成吉思汗，只识弯弓射大雕。".toCharArray();
        poetry[7] = "俱往矣，数风流人物，还看今朝。".toCharArray();

        int maxLength = poetry[0].length; // 最大长度
        for(int i = 1; i < poetry.length; i ++){
            if(poetry[i].length > maxLength){
                maxLength = poetry[i].length;
            }
        }
        Poetry p = new Poetry();
        p.show(maxLength,poetry);
    }

    /**
     * 按照古文方式输出古诗
     * @param maxLength 最长的句子的长度
     * @param poetry  需要输出的数组
     */
    public void show(int maxLength,char[][]poetry){
        for(int i = 0; i < maxLength; i ++){
            for(int j = poetry.length - 1; j >= 0; j --){
                if(i >= poetry[j].length){
                    System.out.print("  ");
                }else{
                    System.out.print(poetry[j][i] + " ");
                }
            }
            System.out.println();
        }
    }

    public void show2(int maxLength,char[][]poetry){
        for(int i = 0; i < maxLength; i ++){
            poetry[i] = Arrays.copyOf(poetry[i],maxLength);
            for(int j = poetry.length - 1; j >= 0; j --){
                System.out.print(poetry[j][i] + " ");
            }
            System.out.println();
        }
    }
}
